// 引入api发请求
import {reqCartList } from '@/api'

const actions = {
    // 发请求获取购物车数据
    async getCartList({commit,state,dispatch,getters},skuNum){
      // 发请求
     let result = await reqCartList(skuNum)
     if (result.code === 200) { 
        // 派发commit
        commit('GETCARTLIST',result.data)
     }
     console.log(result);
    }
}

const mutations = {
  GETCARTLIST(state,value){
      state.cartlist = value  //二次赋值,请求服务器的数据
  }
}

const state = {
    cartlist:{} //准备初始数据
}




const getters = {

}

export default {
  actions,
  mutations,
  state,
  getters
}